--[[
   file:download_access_check.lua
   author:yuan jie
   date:2015-08-04
   description:This lua file is service as url check when download
   vesion: v1.0
   modified history:
--]]


local cjson = require "cjson";
local parser = require "redis.parser";

local res = ngx.location.capture("/redis_get",{args = { key = ngx.var.arg_id }});

if res.status == 200 then

	local reply = parser.parse_reply(res.body);
	if reply == nil then return 404 end
	
	local url_json = cjson.decode(reply);
	if url_json == nil then return 404 end

	--[[ check json valid --]]
	local file_guid = url_json["guid"];
	if file_guid == nil then return 404 end

	--[[ check ok --]]
	return ;
else
	return 404;
end

